#include <gui/screen3_screen/Screen3View.hpp>
extern "C"
{
#include "user_include.h"
}
Screen3View::Screen3View()
{
}

void Screen3View::setupScreen()
{
    Screen3ViewBase::setupScreen();
}

void Screen3View::tearDownScreen()
{
    Screen3ViewBase::tearDownScreen();
}
void Screen3View::handleTickEvent(void)
{
    static int8_t tick = 0;
    static uint16_t para[4] = {1, 23, 34, 23};
    uint8_t i = 0;
    struct tm t;
    tick++;
    if (tick % 6 == 0)
    {
        tick = 0;
        if (driver_button_struct.key_value == BUTTON1_PRESS_FLAG)
        {
            driver_button_struct.key_value = 0;
            application().gotoScreen3ScreenSlideTransitionEast();
        }
        else if (driver_button_struct.key_value == BUTTON2_PRESS_FLAG)
        {
            driver_button_struct.key_value = 0;
            application().gotoscreen2ScreenSlideTransitionEast();
        }
        else if (driver_button_struct.key_value == BUTTON3_PRESS_FLAG)
        {
            driver_button_struct.key_value = 0;
            application().gotoScreen4ScreenSlideTransitionEast();
        }

        if (para[0] == 1)
        {
            Unicode::snprintf(textAreaNetBuffer, 10, "%s", L"on");
        }
        else
        {
            Unicode::snprintf(textAreaNetBuffer, 10, "%s", L"off");
        }
        Unicode::snprintf(textAreaVolBuffer, 10, "%d", para[1]);
        Unicode::snprintf(textAreaSoftBuffer, 10, "%d", para[2]);
        Unicode::snprintf(textAreaHardBuffer, 10, "%d", para[2]);
        box1.invalidate();
        textAreaNet.resizeToCurrentText();
        textAreaVol.resizeToCurrentText();
        textAreaSoft.resizeToCurrentText();
        textAreaHard.resizeToCurrentText();
        textAreaSoft.invalidate();
        textAreaVol.invalidate();
        textAreaNet.invalidate();
        textAreaHard.invalidate();
    }
}
void Screen3View::model_view(uint8_t flag, ...)
{
    int32_t para[10];
    va_list argptr;
    va_start(argptr, flag);

    if (flag == 1)
    {
        para[0] = va_arg(argptr, int32_t);
        if (para[0] == 1)
        {
            application().gotoScreen3ScreenSlideTransitionEast();
        }
        else if (para[0] == 2)
        {
            application().gotoscreen2ScreenSlideTransitionEast();
        }
        else if (para[0] == 3)
        {
            application().gotoScreen4ScreenSlideTransitionEast();
        }
    }
    else if (flag == 3)
    {
        para[0] = va_arg(argptr, int32_t);
        para[1] = va_arg(argptr, int32_t);
        para[2] = va_arg(argptr, int32_t);
        para[3] = va_arg(argptr, int32_t);
        if (para[0] == 1)
        {
            Unicode::snprintf(textAreaNetBuffer, 10, "%s", L"on");
        }
        else
        {
            Unicode::snprintf(textAreaNetBuffer, 10, "%s", L"off");
        }
        Unicode::snprintf(textAreaVolBuffer, 10, "%d", para[1]);
        Unicode::snprintf(textAreaSoftBuffer, 10, "%d", para[2]);
        Unicode::snprintf(textAreaHardBuffer, 10, "%d", para[2]);
        box1.invalidate();
        textAreaNet.resizeToCurrentText();
        textAreaVol.resizeToCurrentText();
        textAreaSoft.resizeToCurrentText();
        textAreaHard.resizeToCurrentText();
        textAreaSoft.invalidate();
        textAreaVol.invalidate();
        textAreaNet.invalidate();
        textAreaHard.invalidate();
    }
    va_end(argptr);
}